<template>
  <el-dropdown trigger="click" @command="handleCommand">
    <span class="el-dropdown-link outline-none">
      <SvgIcon
        icon-name="ant-design:font-size-outlined"
        custom-class="h-[28px] w-[28px] ml-[10px] cursor-pointer"
      ></SvgIcon>
    </span>

    <template #dropdown>
      <el-dropdown-menu>
        <el-dropdown-item
          v-for="item in sizeOptions"
          :key="item.value"
          :command="item.value"
          :disabled="appStore.size === item.value"
        >
          {{ item.label }}
        </el-dropdown-item>
      </el-dropdown-menu>
    </template>
  </el-dropdown>
</template>

<script setup lang="ts" name="SizeSelect">
import type { Size } from "@/plugins/element"
import { useAppStore } from "@/store"
const appStore = useAppStore()

const sizeOptions = [
  {
    value: "default",
    label: "默认"
  },
  {
    value: "large",
    label: "大"
  },
  {
    value: "small",
    label: "小"
  }
]

const handleCommand = (value: Size) => {
  appStore.setSize(value)
}
</script>
